import request from '@/utils/request'

export const getOptions = () => {
  return request({
    method: 'get',
    url: '/course/tad/getOptions',
  })
}


// 获取所有课程
export const getQueryCourses = params => {
  return request({
    method: 'get',
    url: '/course/getAllCourseInfo',
    params
  })
}

export const getUnfreeCourseInfo = params => {
  return request({
    method: 'get',
    url: '/course/getUnfreeCourseInfo',
    params
  })
}


// 获取课程详情
export const getCourseInfo = params => {
  return request({
    method: 'get',
    url: '/course/getCourseInfo',
    params
  })
}

// 编辑课程信息
export const editCourseInfo = data => {
  return request({
    method: 'POST',
    url: '/course/editCourseInfo',
    data
  })
}

// 添加课程
export const addCourseInfo = data => {
  return request({
    method: 'POST',
    url: '/course/addCourseInfo',
    data
  })
}

export const delCourseInfo = params => {
  return request({
    method: 'DELETE',
    url: '/course/delCourseInfo',
    params
  })
}

// 修改上下架状态
export const disableCourseInfo = data => {
  return request({
    method: 'POST',
    url: '/course/disableCourseInfo',
    data
  })
}


// 获取所有章节信息
export const getChapterAndSection = params => {
  return request({
    method: 'get',
    url: '/course/chapter/getChapterAndSection',
    params
  })
}


// 添加章节
export const addChapter = data => {
  return request({
    method: 'POST',
    url: '/course/chapter/addChapter',
    data
  })
}
// 编辑章节
export const editChapter = data => {
  return request({
    method: 'POST',
    url: '/course/chapter/editChapter',
    data
  })
}

// 删除章节
export const delChapter = params => {
  return request({
    method: 'DELETE',
    url: '/course/chapter/delChapter',
    params
  })
}

export const getSectionById = params => {
  return request({
    method: 'get',
    url: '/course/section/getSectionById',
    params
  })
}

// 添加小节
export const addSection = data => {
  return request({
    method: 'POST',
    url: '/course/section/addSection',
    data
  })
}

// 更新小节信息
export const editSection = data => {
  return request({
    method: 'POST',
    url: '/course/section/editSection',
    data
  })
}

// 删除小节
export const delSection = params => {
  return request({
    method: 'DELETE',
    url: '/course/section/delSection',
    params
  })
}


